home *** CD-ROM | disk | FTP | other *** search
/ Speccy ClassiX 1998 / Speccy ClassiX 98.iso / amiga_system / the_aminet / dev / c / asyncio.lha / AsyncIO / src / WriteCharAsync.c < prev   
C/C++ Source or Header  |  1995-09-09  |  637b  |  28 lines

  1. #include "async.h"
  2.  
  3. LibCall LONG
  4. WriteCharAsync( _REG( a0 ) AsyncFile *file, _REG( d0 ) UBYTE ch )
  5. {
  6.     if (file->af_BytesLeft)
  7.     {
  8.         /* if there's any room left in the current buffer, directly write
  9.          * the byte into it, updating counters and stuff.
  10.          */
  11.  
  12.         *file->af_Offset = ch;
  13.         file->af_BytesLeft--;
  14.         ++file->af_Offset;
  15.  
  16.         /* one byte written */
  17.         return( 1 );
  18.     }
  19.  
  20.     /* there was no room in the current buffer, so call the main write
  21.      * routine. This will effectively send the current buffer out to disk,
  22.      * wait for the other buffer to come back, and then put the byte into
  23.      * it.
  24.      */
  25.  
  26.     return( WriteAsync( file, &ch, 1 ) );
  27. }
  28.